package com.sun.btrace.comm;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

public class ClassPairBody  {
	private byte[] code ;
	private String fullName ;
	/*
	 * workaround, add the class to the same path with class of with addToJarOfClass
	 */
	private String addToJarOfClass ;
	public ClassPairBody(String name,byte[] c){
		this.code = c;
		this.fullName = name ;
	}
	protected void read(ObjectInput in) throws IOException,
			ClassNotFoundException {
		// TODO Auto-generated method stub
		fullName = in.readUTF();
		int len=in.readInt();
		code = new byte[len];
		in.readFully(code) ;
		addToJarOfClass = in.readUTF() ;
	}

	protected void write(ObjectOutput out) throws IOException {
		// TODO Auto-generated method stub
		out.writeUTF(fullName) ;
		out.writeInt(code.length);
		out.write(code) ;
		
		out.writeUTF(addToJarOfClass==null?"":addToJarOfClass) ;
	}
	public byte[] getCode() {
		return code;
	}
	public void setCode(byte[] code) {
		this.code = code;
	}
	public String getFullName() {
		return fullName;
	}
	public void setFullName(String fullName) {
		this.fullName = fullName;
	}
	@Override
	public String toString(){
		return this.fullName ;
	}
	public String getAddToJarOfClass() {
		return addToJarOfClass;
	}
	public void setAddToJarOfClass(String addToJarOfClass) {
		this.addToJarOfClass = addToJarOfClass;
	}
}
